<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
     <#assign base=request.contextPath  />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title></title>
    <link rel="stylesheet" href="../frame/layui/css/layui.css">
    <link rel="stylesheet" href="../frame/static/css/style.css">
    <link rel="icon" href="../frame/static/image/code.png">
    <script   src="${base}/jquery-1.8.3.min.js"></script>
    <style type="text/css">
    	.layui-table-fixed-r td{height:58px!important;}
		.layui-table-fixed-r th{height:58px!important;}
		.layui-table img {
		    max-width: 48px;min-height: 48px;
		}


		.laytable-cell-3-wx_headimg ,.laytable-cell-1-wx_headimg,.laytable-cell-2-wx_headimg,.laytable-cell-3-wx_headimg,.laytable-cell-4-wx_headimg,.laytable-cell-5-wx_headimg,.laytable-cell-6-wx_headimg,.laytable-cell-7-wx_headimg,.laytable-cell-8-wx_headimg,.laytable-cell-9-wx_headimg,.laytable-cell-10-wx_headimg,.laytable-cell-11-wx_headimg,.laytable-cell-12-wx_headimg,.laytable-cell-13-wx_headimg,.laytable-cell-14-wx_headimg{
		    width: 48px!important;;padding:0px!important;height: 48px!important;;
		    line-height: 48px!important;;
		}
		.layui-form-item{
			border-bottom: 2px solid #F2F2F2;
		}
		.layui-input-block{
			min-height: 53px;
		}
		img{
			width:110px;height:70px;line-height: 70px;
		}
    </style>
</head>
<body class="body">
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">企业名称</label>
        <div class="layui-input-block">
            <input name="" lay-verify=""  placeholder="请输入企业名称" autocomplete="off" class="layui-input" type="text" id="ptName" value="${Session["user"].getPtname()}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">联系人姓名</label>
        <div class="layui-input-block">
            <input name="" lay-verify="" placeholder="请输入联系人姓名" autocomplete="off" class="layui-input" type="text" id="callName" value="${Session["user"].getCallName()}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">联系人手机</label>
        <div class="layui-input-block">
            <input name="" lay-verify=""  placeholder="请输入手机号" autocomplete="off" class="layui-input" type="text" id="callPhone" value="${Session["user"].getCallPhone()}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"style="height: 70px;" >营业执照<button type="button" class="layui-btn layui-btn-xs layui-btn-normal" id="test2">上传图片</button></label>

       <#if  license!=null>
        <img src="${base}/car/getPhoto?path=${license}"><button type="button" onclick="mov()" >删除原执照</button></label>
        </#if>
        <div></div>


        <div class="layui-upload"><span id="demo2"></span></div>
    </div>
    <div  style="float: right;margin-bottom: 50px ; margin-right: 20px;">
        <div class="layui-input-block">
            <button type="reset" class="layui-btn layui-btn-primary">取消</button>
            <button class="layui-btn layui-btn-normal"  onclick="checc()" type="button">确定</button>
        </div>
    </div>
</form>
<script type="text/javascript" src="../frame/layui/layui.js"></script>
<script type="text/javascript" src="../js/index.js"></script>
<script>
    var fileIds=[];
layui.use(['form','upload'], function(){
  var $ = layui.jquery
  ,form = layui.form
  ,upload = layui.upload;

  //多图片上传
  upload.render({
    elem: '#test2'
    ,url: '${base}/comLicenseFile/upload'
    ,multiple: true
    ,before: function(obj){
      //预读本地文件示例，不支持ie8
      obj.preview(function(index, file, result){
        $('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">')
      });
    }
    ,auto:true
    ,bindAction: '#test9'
    ,done: function(res){
		console.log(res)
    }
      ,done: function(res){
          layer.closeAll('loading'); //关闭loading
          layer.msg(res.msg)
          fileIds.push(res.data.fileId);
      }
  });


});
function checc(){
    var formData={};
    formData.ptName=$("#ptName").val();
    formData.callName=$("#callName").val();
    formData.callPhone=$("#callPhone").val();
    formData.id=${Session["user"].getId()};
    $.ajax({
        type: "post",
        traditional: true,//这里设置为true,不然后台接收到的参数会带上[]，导致数据无法正常接收
        data: {filesId: fileIds ,param:JSON.stringify(formData)},
        url: "${base}/comPtUser/checkup",
        success: function (data) {
            data=JSON.parse(data);
            if (data.flag===true){
                alert("修改成功");

            }else{
                alert("修改失败");
            }


        }
    });
}
    function mov() {
        $.ajax({
            type: "post",
            traditional: true,//这里设置为true,不然后台接收到的参数会带上[]，导致数据无法正常接收
            data: {id:${Session["user"].getId()}},
            url: "${base}/comPtUser/mov",
            success: function (data) {
                if (data==true){
                    alert("删除成功");
                    window.location.href = "${base}/comPtUser/Enterprise.html?id=${Session["user"].getId()}";
                }else{
                    alert("删除失败");
                }
                //这里需要刷新下图片域，暂时没写，找凯旋

            }
        });
    }
<#--function getinfo() {-->
    <#--$.ajax({-->
        <#--type: "post",-->
        <#--traditional: true,//这里设置为true,不然后台接收到的参数会带上[]，导致数据无法正常接收-->
        <#--data: {id:${Session["user"].getId()}},-->
        <#--url: "${base}/comPtUser/license",-->
        <#--success: function (data) {-->


        <#--}-->
    <#--});-->
<#--}-->
</script>
</body>
</html>